/**
 * 
 */
package org.dragonfire.dasm.instr.rules;

import org.dragonfire.dasm.CompileException;
import org.dragonfire.dasm.instr.Rule;
import org.dragonfire.dasm.postprocessor.Postprocessor;

/**
 * @author Darth Android
 * @date Jul 17, 2007
 */
public class Z80RSTRule extends Rule {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.dragonfire.dasm.instr.Rule#evalParam(java.lang.String)
	 */
	@Override
	public String evalParam(Postprocessor post, String bits) {
		int value = Integer.parseInt(bits, 2);
		switch (value) {
			case 0x0:
				return "000";
			case 0x08:
				return "001";
			case 0x10:
				return "010";
			case 0x18:
				return "011";
			case 0x20:
				return "100";
			case 0x28:
				return "101";
			case 0x30:
				return "110";
			case 0x38:
				return "111";
			default:
				throw new CompileException("ERROR_INVALID_VALUE", value, "1st");
		}
	}
}
